package ExamSystemClient.managerSystem.ExamManagement;

import ExamSystemClient.client.ClientScanner;
import ExamSystemClient.model.ChoiceQuestion;
import ExamSystemClient.model.Option;

import java.util.List;

/**
 * 增加考题信息
 *
 * @author huangshuxian
 */
public class AddQuestion extends QuestionManage{

    public AddQuestion(List<ChoiceQuestion> questions) {
        super(questions);
    }

    @Override
    public void operate() {
        //1、提示管理员输入考题信息
        System.out.println("请输入考题编号：");
        int number = ClientScanner.getScanner().nextInt();
        if (getIndexByNumber(number) >= 0){
            System.out.println("该编号已存在！");
            return;
        }
        System.out.println("请输入考题题干：");
        String stem = ClientScanner.getScanner().next();
        System.out.println("请输入选项A");
        Option optionA = new Option(Option.OptionCode.OPTION_A,ClientScanner.getScanner().next());
        System.out.println("请输入选项B");
        Option optionB = new Option(Option.OptionCode.OPTION_B,ClientScanner.getScanner().next());
        System.out.println("请输入选项C");
        Option optionC = new Option(Option.OptionCode.OPTION_C,ClientScanner.getScanner().next());
        System.out.println("请输入选项D");
        Option optionD = new Option(Option.OptionCode.OPTION_D,ClientScanner.getScanner().next());
        System.out.println("请输入正确的选项编号");
        Option.OptionCode rightOption = Option.OptionCode.parse(ClientScanner.getScanner().next());
        //2、将输入信息加入List
        questions.add(new ChoiceQuestion(number, stem, optionA, optionB, optionC, optionD, rightOption));
        System.out.println("增加考题成功！");
    }

    @Override
    public AddQuestion show() {
        System.out.println("增加考题！");
        return this;
    }
}
